#include <stdio.h>
int WordsCount(char list[])
{
	int inWord = 0, count = 0;
	//	inWord, 0:不处于单词中，1:处于单词当中
	for (int i = 0; list[i] != '\0'; i++)
	{
		if (list[i] == ' ')
			inWord = 0;
		else 
			if (inWord == 0)
			{
				inWord = 1;
				count++;
			}
	}
	return (count);
}

int main ( )
{
	char inputString [1000] ;
	int wordCount ;
	printf ( "\n请输入字符串（只包括单词和空格）:\n" );
	gets (inputString);
	wordCount = WordsCount (inputString) ;
	printf ( "单词有%d个\n", wordCount) ;
	return 0;
}

/*
Founded in 2005  Southwest University  SWU  encompasses Southwest Normal University and Southwest Agricultural University  which share an origin dating back to 1906  The school enjoys a long standing history as its fame through ceaseless strive towards academic innovation and integration with social development  As a member of  211 Project  and  Double First class  universities  SWU has an extensive set of disciplinary categories including philosophy  economics  law  pedagogy  literature  history  science  engineering  agriculture  medicine  management and art  It is especially known for its distinctive teacher education and agricultural education 
  

 */
